package com.ansion.baseui.base.listener;

import androidx.annotation.NonNull;

import com.ansion.basetool.observer.ListenerManager;
import com.ansion.basetool.preconditions.Preconditions;


public class PageChangeNotifier extends ListenerManager<OnPageChangeListener> {
    private static final PageChangeNotifier INST = new PageChangeNotifier();

    public PageChangeNotifier() {
        super(true);
    }

    public static PageChangeNotifier getInstance() {
        return INST;
    }


    public void notifyPageSelected(@NonNull String key, int page) {
        Preconditions.checkNotEmpty(key);
        notifyListeners(customListItemListener -> {
            if (customListItemListener.match(key)) {
                customListItemListener.onPageSelected(page);
            }
        });
    }


}
